﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SqlAntlr
{
    public interface IView
    {

        int getCardinality();

        /**
         * @param selected if <code>true</code>, return only selected columns. Otherwise, return all columns defined in FROM clause.
         * @return {@link edu.washington.db.cqms.common.sqlparser.Column Column} objects according to <code>selected</code> parameter.
         */
        IList<Column> getColumns(bool selected);

        /**
         * retrieve {@link edu.washington.db.cqms.common.sqlparser.Column Column} 
         * objects in given specification.
         * @param n name (or alias) of column
         * @param selected <code>true</code> if only look for SELECT clause. <code>false</code> will consider entire columns exposed by views in FROM clause
         */
        Column getColumn(String n, bool selected);

        /**
         * retrieve the first selected column
         */
        Column getFirstColumn();

        /**
         * @return alias of this view. <code>null</code> if there is no alias
         */
        String getAlias();

        /**
         * @return real name of this view. only returns different value if 
         * this object is a concrete table.
         */
        String getRealName();

        void setAlias(String s);

        /**
         * get {@link edu.washington.db.cqms.common.sqlparser.View View} which
         * has this object in its SELECT clause
         */
        IView getParent();       // get parent view

        /**
         * get {@link edu.washington.db.cqms.common.sqlparser.View view} which
         * has the name <code>s</code> in the FROM clause.
         *
         * @param s name of view
         * @return the object named as <code>s</code> or <code>null</code>
         */
        IView getView(String s); // does x is defined in this view?

        /**
         * check whether the two views are identical.
         * @return <code>true</code> if they are identical.
         */
        bool isSame(IView v);

        String toObjectString();
    }
}
